/*DxfVERTEX.java
 *
 * Created on 6 de Dezembro de 2007, 9:35 by rafaelbuck
 * 
 * Modified on 08/10/2011, 00:20 PM by Adriano
 * Included the attributes @Override to inherented methods
 */

package importadorDXF;

import mathematics.Point3D;

/**
 * @author rafaelbuck
 * @author Adriano Ferreira
 */
public class DxfVERTEX extends DxfEntity
{
    @Override
    public boolean setGroup(short grpNr, float fval)
    {
        switch(grpNr)
        {
            case 10: // '\n'
            case 20: // '\024'
            case 30: // '\036'
                setCoord(position, grpNr / 10, fval);
                return true;

            case 40: // '('
                startWidth = fval;
                return true;

            case 41: // ')'
                endWidth = fval;
                return true;

            case 42: // '*'
                rounding = fval;
                return true;

            case 50: // '2'
                tangent = fval;
                return true;
        }
        
        return super.setGroup(grpNr, fval);
    }

    @Override
    public boolean setGroup(short grpNr, int ival)
    {
        switch(grpNr)
        {
            case 70: // 'F'
                type = ival;
                return true;

            case 71: // 'G'
            case 72: // 'H'
            case 73: // 'I'
            case 74: // 'J'
                if(index == null)
                {
                    index = new int[4];
                    for(int i = 0; i < 4; i++)
                        index[i] = 0;

                }
                index[grpNr - 71] = ival;
                return true;
        }
        
        return super.setGroup(grpNr, ival);
    }

    @Override
    public void convert(DxfConverter dxfconverter, DxfFile dxffile, Object obj)
    {
    }

    public final Point3D getPosition()
    {
        return position;
    }

    public final int getType()
    {
        return type;
    }

    public final float getStartWidth()
    {
        return startWidth;
    }

    public final float getEndWidth()
    {
        return endWidth;
    }

    public void setWidths(float startWidth, float endWidth)
    {
        this.startWidth = startWidth;
        this.endWidth = endWidth;
    }

    public void setStartWidth(float startWidth)
    {
        this.startWidth = startWidth;
    }

    public void setEndWidth(float endWidth)
    {
        this.endWidth = endWidth;
    }

    public final float getRounding()
    {
        return rounding;
    }

    public final float getTangent()
    {
        return tangent;
    }

    public final int[] getReferences()
    {
        return index != null ? index : new int[4];
    }

    /** Creates a new instance of DxfVERTEX */
    public DxfVERTEX()
    {
        position = new Point3D();
        startWidth = -1F;
        endWidth = -1F;
    }

    protected Point3D position;
    protected int type;
    protected float startWidth;
    protected float endWidth;
    protected float rounding;
    protected float tangent;
    protected int index[];
    public static final int FIT_POINT = 1;
    public static final int TANGENT = 2;
    public static final int LINE_FIT = 8;
    public static final int CONTROL = 16;
    public static final int LINE_3D = 32;
    public static final int WEB_3D = 64;
    public static final int NET_CONTROL = 128;
    public static final int APPROX = 9;
    public static final int NO_INDEX = 0;
    public static final int PFACEVMAX = 4;
}